package com.moss.cloud.log.model.po;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 登录日志
 * @author 瑾年
 * @date 2023年3月16日
 */
@Data
@Document(collection="login_log")
public class LoginLog implements Serializable {
    private static final long serialVersionUID = -8985545025018238754L;
    public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    @Id
    private String id;
    /**
     * 登录人
     */
    private String userName;
    /**
     * 登录设备
     */
    private String equipment;
    /**
     * 登录IP地址
     */
    private String remoteIp;
    /**
     * 登录时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = DATE_FORMAT)
    private LocalDateTime loginTime;
    /**
     * 登录状态
     */
    private String loginStatus;
    /**
     * 租户ID
     */
    private Long tenantId;
}
